﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace WF.Web.Controls
{
    public class CCHR_ObjectDataSource : ObjectDataSource
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.ObjectCreating += new ObjectDataSourceObjectEventHandler(CCHR_ObjectDataSource_ObjectCreating);
        }

        void CCHR_ObjectDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            Classes.IViewModelPage vmPage = this.Page as Classes.IViewModelPage;
            if (vmPage != null)
                e.ObjectInstance = vmPage.GetViewModel();
        }
    }
}